package cn.iocoder.yudao.module.eval.dal.mysql.profession;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.eval.controller.admin.profession.vo.EvalProfessionPageReqVO;
import cn.iocoder.yudao.module.eval.dal.dataobject.profession.EvalProfessionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 职业工种 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EvalProfessionMapper extends BaseMapperX<EvalProfessionDO> {

    default PageResult<EvalProfessionDO> selectPage(EvalProfessionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EvalProfessionDO>()
                .likeIfPresent(EvalProfessionDO::getProfessionCode, reqVO.getProfessionCode())
                .likeIfPresent(EvalProfessionDO::getProfessionName, reqVO.getProfessionName())
                .eqIfPresent(EvalProfessionDO::getProfessionCategory, reqVO.getProfessionCategory())
                .eqIfPresent(EvalProfessionDO::getApprovalStatus, reqVO.getApprovalStatus())
                .betweenIfPresent(EvalProfessionDO::getFilingDate, reqVO.getFilingDate())
                .betweenIfPresent(EvalProfessionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EvalProfessionDO::getId));
    }

    default EvalProfessionDO selectByProfessionCode(String professionCode) {
        return selectOne(EvalProfessionDO::getProfessionCode, professionCode);
    }

    default List<EvalProfessionDO> selectListByApprovalStatus(Integer approvalStatus) {
        return selectList(EvalProfessionDO::getApprovalStatus, approvalStatus);
    }

    default List<EvalProfessionDO> selectListByCategory(String category) {
        return selectList(EvalProfessionDO::getProfessionCategory, category);
    }

}
